package com.jxw.gk;

import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jxw.launcher.util.Util;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;

/* loaded from: classes.dex */
public class GkAppUseInfo {
    private static GkAppUseInfo gkAppUseInfo;
    public List<AppUseInfo> datas;

    public static GkAppUseInfo getGkAppUseInfo() {
        if (gkAppUseInfo == null) {
            gkAppUseInfo = new GkAppUseInfo();
        }
        return gkAppUseInfo;
    }

    public void getAppUseInfo() {
        try {
            if (TextUtils.isEmpty(SPUtils.getToken())) {
                return;
            }
            new OkHttpClient().newCall(new Request.Builder().addHeader("token", SPUtils.getToken()).url(Util.GK_APPLIST).get().build()).enqueue(new Callback() { // from class: com.jxw.gk.GkAppUseInfo.1
                @Override // okhttp3.Callback
                public void onFailure(Call call, IOException iOException) {
                    iOException.getMessage();
                }

                @Override // okhttp3.Callback
                public void onResponse(Call call, Response response) throws IOException {
                    try {
                        JSONObject jSONObject = new JSONObject(response.body().string());
                        if ("0".equals(jSONObject.optString("code"))) {
                            Type type = new TypeToken<Collection<AppUseInfo>>() { // from class: com.jxw.gk.GkAppUseInfo.1.1
                            }.getType();
                            GkAppUseInfo.this.datas = (List) new Gson().fromJson(jSONObject.optJSONArray("data").toString(), type);
                        }
                    } catch (Exception unused) {
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
